﻿using Framework.CapaDeDatos.Convertores;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Framework.Modelo;
using System.Xml;
using Rhino.Mocks;
using System.Reflection;
using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
using Framework.Atributos;
using System.Collections.Generic;

namespace FrameworkTest.CapaDeDatosTest
{
    [TestClass()]
    public class ConvertorXmlTest
    {
        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [TestMethod()]
        public void ObtenerXmlTestWithNull()
        {
            IObjeto objeto = null;
            XmlDocument actual;
            actual = ConvertorXml.Obtener(objeto);
            Assert.IsNull(actual);
        }

        [TestMethod()]
        public void ObtenerXmlTestWithInstance()
        {
            IObjeto objeto = new Objeto();
            XmlDocument actual;
            actual = ConvertorXml.Obtener(objeto);
            Assert.IsNotNull(actual);
            Assert.IsInstanceOfType(actual, typeof(XmlDocument));
            Assert.IsNotNull(actual.ChildNodes);
            Assert.IsTrue(actual.ChildNodes.Count > 0);
            foreach (XmlNode xn in actual.ChildNodes)
            {
                Assert.IsNotNull(xn);
            }
        }


        [TestMethod()]
        public void ObtenerIObjetoTestWithNull()
        {
            XmlDocument document = null;
            IObjeto expected = null;
            IObjeto actual;
            actual = ConvertorXml.Obtener(document);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void ObtenerIObjetoTestWithInstance()
        {
            XmlDocument document = null;
            IObjeto expected = new Objeto();
            IObjeto actual;
            document = ConvertorXml.Obtener(expected);
            actual = ConvertorXml.Obtener(document);
            Assert.AreEqual(expected, actual);
        }
    }
}
